<?php
session_start();
/*
 * O'My Friends
 * friendship.php
 * show the friend's interactivities
 */
$lib_dir = dirname(__FILE__).'/lib/';
require_once $lib_dir.'config.php';
require_once $lib_dir.'facebook.php';
require_once $lib_dir.'util.php';
require_once $lib_dir.'friend.php';
require_once $lib_dir.'friends.php';
require_once $lib_dir.'view.php';
require_once $lib_dir.'init.php';

$fId = $_REQUEST['fId'];

$f = null;

if($session){
    try{
        $f = $facebook->api('/'.$fId);
    }catch(Exception $e){
        error_log($e);
    }
}

$html = getTemplateHTML("Friendship");

//Log in and out button
$html = str_ireplace("[##_LOGINOUT_BUTTON_##]", ($f)? $logout_button : $login_button, $html);
$html = str_ireplace("[##_FACEBOOK_ASYNC_LOADING_CODE_##]", null , $html);
$html = str_ireplace("[##_FRIEND_NAME_##]", ($f) ? "with ".$f['name']: null, $html);
$html = str_ireplace("[##_AJAX_FUNCTION_##]", ($f) ? "getFriendHistoryAJAX($fId);" : null, $html);

$html =str_ireplace("[##_USER_ID_##]", $session['uid'], $html);

print($html);
?>
